<template>
  <el-card>
    <el-table
      ref="singleTable"
      :data="tableData"
      highlight-current-row
      @current-change="handleCurrentChange"
      style="width: 100%"
    >
      <el-table-column type="index" width="50"> </el-table-column>
      <el-table-column property="order_no" label="单号"> </el-table-column>
      <el-table-column property="name" label="状态"> </el-table-column>
      <el-table-column property="name" label="用户"> </el-table-column>
      <el-table-column property="name" label="手机"> </el-table-column>
      <el-table-column
        property="created_time"
        label="添加时间"
        :formatter="formatTime"
        width="140"
      >
      </el-table-column>
      <el-table-column fixed="right" label="操作" width="140">
        <template #default="scope">
          <el-button text size="small" @click="handleEdit">编辑</el-button>
          <el-button
            text
            type="warning"
            size="small"
            @click="deleteP(scope.row)"
            >删除</el-button
          >
        </template>
      </el-table-column>
    </el-table>
  </el-card>

  <el-dialog
    title="新增菜品分类"
    v-model="dialogVisible"
    width="20%"
    center
    :before-close="handleClose"
  >
    <div class="dialog-content">
      <el-input placeholder="请输入名称" v-model="categoryForm.name"></el-input>
      <div class="dialog-footer">
        <el-button @click="dialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="addCategory">确 定</el-button>
      </div>
    </div>
  </el-dialog>
</template>

<script setup>
import { ref, onMounted, computed } from "vue";
import {
  orderList,
} from "@/network/product";
import dayjs from "dayjs";
const currentRow = ref(null);
const tableData = ref([]);

const dialogVisible = ref(false);
const categoryForm = ref({ name: "" });

onMounted(() => {
  loadOrders();
});
const formatTime = (row, column, cellValue, index) => {
  // return col;
  return dayjs(cellValue).format("YYYY-MM-DD HH:ss");
};
const loadOrders = () => {
  orderList({}).then((list) => {
    tableData.value = list.data;
  });
};


const handleOpen = () => {
  dialogVisible.value = true;
};

const handleClose = () => {
  dialogVisible.value = false;
};

const handleEdit = (index, row) => {};

const handleDelete = (index, row) => {};

const setCurrent = (row) => {
  // singleTable.setCurrentRow(row);
};

const handleCurrentChange = (val) => {
  currentRow.value = val;
};
</script>

<style scoped>
.dialog-content {
  margin-bottom: 40px;
  text-align: center;
}

.dialog-footer {
  margin-top: 40px;
  display: flex;
  flex-direction: row;
  justify-content: space-around;
}
.filter-wrapper {
  padding-bottom: 20px;
  box-sizing: border-box;
}
.el-header,
.el-footer {
  background-color: #b3c0d1;
  color: #333;
  text-align: center;
  line-height: 60px;
}

.el-aside {
  background-color: #545c64;
  color: #333;
  text-align: center;
  line-height: 200px;
}

.el-main {
  background-color: #e9eef3;
  color: #333;
}

.el-container:nth-child(5) .el-aside,
.el-container:nth-child(6) .el-aside {
  line-height: 260px;
}

.el-container:nth-child(7) .el-aside {
  line-height: 320px;
}

.el-menu-vertical-demo:not(.el-menu--collapse) {
  width: 200px;
  min-height: 400px;
}
</style>